/*
 * Copyright (c) $today.year-Now http://www.zxpnet.com All rights reserved.
 */

package com.zxp.springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.util.UrlPathHelper;

/**
 * @author: shollin
 * @date: 2021/6/29/029 18:48
 */
@Configuration
public class WebConfig {

    @Bean
    public WebMvcConfigurer webMvcConfig() {
        return new WebMvcConfigurer(){

            // 启用矩阵变量功能 @GetMapping("/boss/{bossId}/{empId}") /boss/1;age=20/2;age=10
            @Override
            public void configurePathMatch(PathMatchConfigurer configurer) {
                UrlPathHelper urlPathHelper = new UrlPathHelper();
                // 不移除；后面的内容。矩阵变量功能就可以生效
                urlPathHelper.setRemoveSemicolonContent(false);
                configurer.setUrlPathHelper(urlPathHelper);
            }

            @Override
            public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
                WebMvcConfigurer.super.configureContentNegotiation(configurer);
            }
        };
    }
}
